import { ref, type Ref, onMounted } from 'vue'
import { useRouter } from 'vue-router'
import { useCollectionStore } from '@/stores/collection'
export const useColleciton = () => {
    //返回上一级
    const onClickLeft = () => history.back()

    //选择控制
    let state: Ref<boolean> = ref(false)
     
    const bindSwitch = () => {
        state.value = !state.value
        CollectionStore.init()
        
    }

    //调用pinia
    const CollectionStore = useCollectionStore()

    //跳转
    const router=useRouter()
    const bindJump=(id:number)=>{
        if(!state.value){
            router.push({path:'/detail',query:{id,}})
        }
       
        
    }
   
    return {  onClickLeft, bindSwitch, state, CollectionStore,bindJump,}
}
